#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,m,l,V,t,d[100005],v[100005],a[100005],c[100005];
int farest[3005][3005];
int si[3005];
int ans=0;
pair<int,vector<int> >  cars[100005];
void st(){
	ans=0,n=0,m=0,l=0,V=0;
	memset(d,0,sizeof(d));
	memset(v,0,sizeof(v));
	memset(a,0,sizeof(a));
	memset(c,0,sizeof(c));
	memset(farest,0,sizeof(farest));
	memset(si,0,sizeof(si));
	for(int i = 0;i < 100005;i++) cars[i].second.clear(),cars[i].first=0;
	return;
}
int sqt(int x){
	int res=(int)sqrt(x);
	if(res*res<x) res++;
	return res;
}	
int dsy(int x){
	int res=(V*V-v[x]*v[x])/(2*a[x]);
	if(res*2*a[x]<(V*V-v[x]*v[x])) res++;
	return res;
}
bool check(int x){
	for(int i = 1;i <= n;i++){
		if(si[i]==1 and farest[i][x]==1) return false;
	}
	return true;
}
void work(int x){
	for(int i = 1;i <= n;i++){
		if(farest[i][x])farest[i][x]=0,si[i]--;
	}
	return;
}
signed main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	scanf("%lld",&t);
	while(t--){
		st();
		ans=0;
		ans=0;
		ans=0;
		ans=0;
		ans=0;
	//	cerr<<"ruok?"<<endl;
	//	cerr<<ans<<endl;
		scanf("%lld %lld %lld %lld",&n,&m,&l,&V);
		if(n>3000 or m>3000){
			cerr<<"too big"<<endl;
			return 0;
		}
		for(int i = 1;i <= n;i++){
			scanf("%lld %lld %lld",&d[i],&v[i],&a[i]);
		}
		for(int i = 1;i <= m;i++) scanf("%lld",&c[i]);
		sort(c+1,c+1+n);
		for(int i = 1;i <= n;i++){
		//	cerr<<i<<":"<<endl;
			for(int j = 1;j <= m;j++){
				if(c[j]<d[i])continue;
				if(v[i]*v[i]+2*a[i]*(c[j]-d[i])>V*V)farest[i][j]=1,si[i]++,cars[j].second.push_back(i),cars[j].first++;
		//		cerr<<v[i]<<" "<<a[i]<<" "<<d[i]<<" "<<c[j]<<endl;
			}
			ans+=(bool)si[i];
		}	
		sort(cars+1,cars+1+n);
		int cnt=0;
		for(int i = 1;i <= m;i++){
			if(check(i)){
				work(i);
				cnt++;
			}
		}
		printf("%lld %lld\n",ans,cnt);
		
	}
	return 0;
}//expect:60,at least :0
